<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 100px;
            height: 100px;
            background-color: red;
            border: black 2px solid;
            padding: 10px;
            box-sizing: border-box;
        }
    </style>
</head>
<body>
    <div class="box">

    </div>
    <script>
        /*
            js中提供了两种用来获取元素尺寸的方式
                - clientWidth、clientHeight: (content+padding)
                - offsetWidth、offsetHeight: (content+padding+border)
            不过要注意display:none的时候是没法获取到的，怪异盒模型下clientWidth会受到挤压
        */ 
       let box = document.querySelector('.box')
       console.log(box.clientWidth,box.clientHeight)
       console.log(box.offsetWidth,box.offsetHeight);
    </script>
</body>
</html>